// Border.cpp: implementation of the CBorder class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Border.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

void CBorder::DrawInBorder(CDC* pDC , CRect rt,COLORREF tc,COLORREF bc)
{
	CPen pent,penb ;
	pent.CreatePen(PS_SOLID,1,tc) ; 
	penb.CreatePen(PS_SOLID,1,bc) ; 
	CPen* oldPen = pDC->SelectObject(&pent) ;
	pDC->MoveTo( rt.right-1,rt.top ) ; 
	pDC->LineTo( rt.left ,rt.top ); 	
	pDC->LineTo( rt.left,rt.bottom ); 

	pDC->MoveTo( rt.right-2,rt.top+1 ) ; 
	pDC->LineTo( rt.left+1 ,rt.top+1 ); 	
	pDC->LineTo( rt.left+1,rt.bottom-1 ); 

	pDC->SelectObject(&penb) ;
	pDC->MoveTo( rt.right , rt.top+1 );
	pDC->LineTo( rt.right , rt.bottom ) ;
	pDC->LineTo( rt.left , rt.bottom ) ; 

	pDC->MoveTo( rt.right-1 , rt.top+2 );
	pDC->LineTo( rt.right-1 , rt.bottom-1 ) ;
	pDC->LineTo( rt.left+1 , rt.bottom-1 ) ; 
	
	pDC->SelectObject(oldPen);
}

CBorder::CBorder()
{

}

CBorder::~CBorder()
{

}

BOOL CBorder::Load(UINT top1,UINT top2,UINT top3,
				   UINT bottom1,UINT bottom2,UINT bottom3,
				   UINT left,UINT right)
{
	if( !m_TopBar.Create(FALSE,top1,top2,top3) )
		return FALSE ;
	if( !m_BottomBar.Create(FALSE,bottom1,bottom2,bottom3) )
		return FALSE ;
	
	if( !m_LeftBar.Create(TRUE,left,0,0) )
		return FALSE ;
	if( !m_RightBar.Create(TRUE,right,0,0) )
		return FALSE ;

	return TRUE ;
}

void CBorder::Draw(CDC* pDC , CRect rt)
{
	CPoint pt ;
	int h = rt.Height()-m_TopBar.GetWidth()-m_BottomBar.GetWidth(); 
	pt = rt.TopLeft() ;
	m_TopBar.Draw(pDC,pt,rt.Width());
	pt.y += m_TopBar.GetWidth() ;
	m_LeftBar.Draw(pDC,pt,h); 
	pt.x = rt.right - m_RightBar.GetWidth() ;
	m_RightBar.Draw(pDC,pt,h); 
	pt.x = rt.left ;
	pt.y = rt.bottom - m_BottomBar.GetWidth(); 
	m_BottomBar.Draw(pDC,pt,rt.Width()); 

 }